package de.bazinga.rotw.network.message;

import com.captiveimagination.jgn.message.Message;
import com.captiveimagination.jgn.message.type.CertifiedMessage;
import com.captiveimagination.jgn.message.type.PlayerMessage;
import com.captiveimagination.jgn.message.type.TimestampedMessage;
import com.jme.math.Vector3f;

import de.bazinga.rotw.game.RotwGameState;
import de.bazinga.rotw.gameModes.CaptureTheZombie;
import de.bazinga.rotw.zombie.Waypoint;

public class ZombieWaypointMessage extends Message implements CertifiedMessage, PlayerMessage, TimestampedMessage, GameMessage {	
	private int zombieIndex = 1;
	
	private Vector3f waypoint = null;
	private Vector3f zombieLocation = null;

	public Vector3f getZombieLocation() {
		return zombieLocation;
	}

	public void setZombieLocation(Vector3f zombieLocation) {
		this.zombieLocation = zombieLocation;
	}

	public int getZombieIndex() {
		return zombieIndex;
	}

	public void setZombieIndex(int zombieIndex) {
		this.zombieIndex = zombieIndex;
	}

	public Vector3f getWaypoint() {
		return waypoint;
	}

	public void setWaypoint(Vector3f waypoint) {
		this.waypoint = waypoint;
	}


	
	
	public void handleMessage(RotwGameState game, Message msg, boolean server) {
		if(!(msg instanceof ZombieWaypointMessage)) return ;

		// Player touched a item
		ZombieWaypointMessage message = (ZombieWaypointMessage)msg;
		
		if(server) {
			
		}else{
			// The Zombie got a new Waypoint to go to
			((CaptureTheZombie)game.getGameMode()).getZombie(message.getZombieIndex()).setLocalTranslation(
					message.getZombieLocation());
			((CaptureTheZombie)game.getGameMode()).getZombie(message.getZombieIndex()).getZombieController()
				.setCurrentWaypoint(new Waypoint(message.getWaypoint()));
		}
	}
}